﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace ibba.src.noriskbo.code.converter
{
    public class SimNaoConverter : IValueConverter
    {

        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool valor;

            try
            {
                valor = (bool)value;

                if (parameter != null)
                {
                    switch (parameter.ToString().ToLower())
                    {
                        case "visibility":
                            return (valor ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed);

                        case "image":
                            return (valor ? Constantes.SourceImageApp.CHECKED_MINI : Constantes.SourceImageApp.UNCHECKED_MINI);

                        default:
                            return DependencyProperty.UnsetValue;
                    }
                }
                else
                {
                    return (valor ? "Sim" : "Não");
                }

            }
            catch (Exception)
            { }

            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value;
        }

        #endregion
    }
}
